<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://ckfinder.com" prefix="ckfinder" %>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>

<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <logic:lessThan name="buildingForm" property="buildingID" value="1">
            <h2>Add Building</h2>
        </logic:lessThan>
        <logic:greaterThan name="buildingForm" property="buildingID" value="0">
            <h2>Edit Building "<bean:write name="buildingForm" property="buildingID"/>"</h2>
        </logic:greaterThan>
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleId="buildingForm" action="admin/building.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <h2>Land</h2><br/>
            <p>
                <html:hidden property="landID" />
                <label>ID: </label>
                <span class="text"><bean:write name="land" property="landID"/></span>
            </p>
            <p>
                <label>Address: </label>
                <span class="text"><bean:write name="land" property="address"/></span>
            </p>
            <p>
                <label>Location: </label>
                <span class="text"><bean:write name="land" property="locationName"/></span>
            </p>
            <p>
                <label>Plan Laid: </label>
                <span class="text"><bean:write name="land" property="planName"/></span>
            </p>
            <p>
                <label>Area: </label>
                <span class="text"><bean:write name="land" property="landArea"/>
                &nbsp;sq.foot</span>
            </p>
            <p>
                <label>Near by (Landmarks): </label>
                <span class="text"><bean:write name="land" property="nearByLandMarks"/></span>
            </p>
            <hr/>
            <br/><br/>
            <h2>Building</h2><br/>
            <logic:greaterThan name="buildingForm" property="buildingID" value="0">
                <label>Building ID: </label><span class="text"><bean:write name="buildingForm" property="buildingID"/></span>
            </logic:greaterThan>
            <p>
                <html:hidden property="buildingID" />
                <label for="buildingName">Building Name:</label><span class="required">*</span><br/>
                <html:text styleId="buildingName" styleClass="text medium required" property="buildingName"/>
            </p>
            <p>
                <label for="buildingTypeID">Building Type:</label><span class="required">*</span><br/>
                <html:select styleId="bf_buildingTypeID" property="buildingTypeID">
                    <option value="">-- Select --</option>
                    <logic:iterate id="buildingType" name="buildingTypeList">
                        <html:option value="${buildingType.buildingTypeID}">${buildingType.buildingTypeName}</html:option>
                    </logic:iterate>
                </html:select>
                <label for="bf_buildingTypeID" class="error" generated="true" style="display:none;"></label>
            </p>
            <p>
                <label for="numFloors">Number Of Floors:</label><span class="required">*</span><br/>
                <html:text styleId="numFloors" styleClass="text small required number" property="numFloors"/>
            </p>
            <p>
                <label for="numRooms">Number Of Rooms</label><span class="required">*</span><br/>
                <html:text styleId="numRooms" styleClass="text small required number" property="numRooms"/>
            </p>
            <p>
                <label for="constructedDate">Constructed Date:</label><span class="required">*</span><br/>
                <html:text styleId="constructedDate" styleClass="text date_picker required dateISO" property="constructedDate"/>
                <label for="constructedDate" class="note">(yyyy-MM-dd)</label>
                <label for="constructedDate" class="error" generated="true" style="display:none;"></label>
            </p>
            <p>
                <label>Description:</label><br/>
                <html:textarea property="description"/>
                <ckfinder:setupCKEditor basePath="/ckfinder/" editor="description"  />
                <ckeditor:replace basePath="/ckeditor/" replace="description" />
            </p>  
            
            <hr/>
            
            <p>
                <html:submit property="action" value="Save" styleClass="submit small"/>    
                <logic:greaterThan name="buildingForm" property="buildingID" value="0">
                    <html:submit property="action" value="Save & Exit" styleClass="submit mid"/>
                    <html:link styleClass="confirm-button submit small red" action="/admin/buildingListing.do?action=delete" paramId="buildingID" paramName="buildingForm" paramProperty="buildingID">
                        Delete
                    </html:link>
                </logic:greaterThan>
                <html:link action="/admin/buildingListing.do" styleClass="submit small gray">Cancel</html:link>
            </p>
            
            
        </div>
        <!-- .block_content ends -->
    </html:form>
        
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->
